fix(graph): nullable latestCloudEvent/latestIndex so empty sources don't tank sibling aliases#85
Merged
Conversation
A source with no matching event made the non-null latestCloudEvent field
error ("no cloud events found"), and GraphQL null-propagation bubbled the
null to the root `data` — tanking every sibling alias in an aliased
multi-source query. dimo-app-backend's getName batches per-source nickname
lookups this way, so a vehicle whose owner had a nickname but whose
dev-license source did not resolved to no name at all (e.g. token 22892
"Loux Transport").
Make latestCloudEvent and latestIndex nullable and return (nil, nil) on
sql.ErrNoRows (mirroring the cloudEvents/indexes list resolvers), so an
empty source resolves to null without poisoning its siblings. Regenerate
gqlgen. Add a ClickHouse-backed regression test over the aliased path.
5d4c289 to
97918b3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
latestCloudEvent(andlatestIndex) were non-nullable (CloudEvent!), and the resolver returned asql.ErrNoRows-wrapped error ("no cloud events found") for any source with no matching event. In an aliased multi-source query, GraphQL null-propagation from the errored non-null field bubbles up and nulls the entiredataobject — wiping every sibling alias that did resolve.dimo-app-backend's
getNamebatches per-source nickname lookups[caller, owner, dev-license]as aliases in one request. The dev-license source rarely has a per-vehicle nickname, so its alias always errored → the owner's real nickname was wiped →/v2/vehicles/:id/summaryreturned no name (e.g. token 22892 "Loux Transport").Fix
latestCloudEventandlatestIndexnullable in the schema.(nil, nil)onerrors.Is(err, sql.ErrNoRows)— mirroring the existingcloudEvents/indexeslist resolvers — so an empty source resolves tonullwithout poisoning its siblings.marshalN*→marshalO*).Test
internal/graph/null_propagation_test.go: ClickHouse-backed aliasedlatestIndexquery with one populated + one empty source. Verified red without the fix (fails with the exactno cloud events foundsignature), green with it.